var bookId = 0;

//赋值
(function setReplyApplyForm() {
	var form = $("#replyApplyForm");
	var param = $('#replyApplyWindow').panel('options').param;
	var row = param.row;
	var template = param.template;
	if (row) {
		$(form).form("load", row);
		bookId = row.bookId;
		var bookStatus = $("#bookStatus");
		var bookResultText = $("#bookResultText");
		
		bookStatus.combobox({
			onChange: function(newValue, oldValue)
			{
				if(newValue == -1)
					bookResultText.val("");
				else if(newValue == 1)
					bookResultText.val(template);
			}
		});
		if (row.bookStatus == 0) {
			bookStatus.removeAttr("disabled");
			bookResultText.val(template);
		} else {
			bookStatus.attr("disabled", "disabled");
			bookResultText.val(row.bookResultText);
		}
	} else {
		$(form).form("load", []);
	}
})();

function subReplyForm() {
	alert("asad");
	var bookStatus = $("#bookStatus1").val();
	alert(bookStatus);
	var bookResultText = $("#bookResultText").val();
	if (bookResultText == "") {
		alert("请填写审核结果!");
		return false;
	}
	$.post("SaveReply", {bookId : bookId, bookStatus : bookStatus, bookResultText : bookResultText }, function(text) {
		var data = (new Function("return " + text))();
		alert(data.status);
		if (data.status == '审核成功') {
			var param = $('#replyApplyWindow').panel('options').param;
			var row = param.row;
			var index = param.index;
			row.bookStatus = bookStatus;
			row.bookResultText = bookResultText;
			param.callback(row, index);
			$("#replyApplyWindow").window('close');
		}
	});
}
